package main

import (
	"encoding/json"
	"fmt"
)

type Order struct {
	Id         string `json:"id"`
	Name       string `json:"name"`
	Quantity   int    `json:"quantity"`
	TotalPrice int    `json:"total_price"`
}

func main() {
	o := Order{
		"1234", "haha", 3, 30,
	}
	fmt.Printf("%+v\n", o)
	b, err := json.Marshal(o)
	if err != nil {
		panic(err)
	}
	fmt.Printf("%s\n", b)
	var o1 Order
	s := string(b)
	err = json.Unmarshal([]byte(s), &o1)
	if err != nil {
		panic(err)
	}
	fmt.Printf("%+v\n", o1)
}
